const conicColors = {
  '0%': '#87d068',
  '50%': '#ffe58f',
  '100%': '#ffccc7'
}

const progressSize = 60

const items = (batteryInf, t) => {
  const items_ = [
    {
      title: t('cpu'),
      active: true
    },
    {
      title: t('disk'),
      active: false
    },
    {
      title: t('mem'),
      active: false
    }
  ]

  if (batteryInf.hasBattery) {
    items_.push({
      title: t('battery'),
      active: false
    })
  }

  return items_
}

const setActive = (idx) => {
  items().forEach((item, index) => {
    item.active = index === idx
  })
}

const active = {
  color: '#3498DB',
  fontWeight: 'bold',
  fontSize: '14px'
}

const inactive = {
  color: '#b9c4d1',
  fontSize: '13px'
}

const activeShadow = {
  boxShadow: '0 10px 10px rgba(0,0,0,0.5)'
}

/**
 * 设置数据
 * @param setData
 * @param setBatteryInf
 * @param setTopInfo
 */
const setTopData = (setData, setBatteryInf, setTopInfo) => {
  let interval = setInterval(() => {
    const { getData } = window.api.data
    const dt = getData()
    setData(dt)
    setBatteryInf(dt.batteryInf)
    setTopInfo([...window.topInfo])
  }, 200)

  setTimeout(() => {
    clearInterval(interval)
    setInterval(() => {
      const { getData } = window.api.data
      const dt = getData()
      setData(dt)
      setBatteryInf(dt.batteryInf)
      setTopInfo([...window.topInfo])
    }, 2000)
  }, 500)
}

export { conicColors, progressSize, items, setActive, active, activeShadow, inactive, setTopData }
